using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PACKETPARSERMAX20.CORE;

namespace PACKETPARSERMAX20.CORE.DEFINITIONS
{
    public class SMSG_QUESTGIVER_QUEST_DETAILS_DEF : DefinitionBase
    {

        public override bool Process()
        {
            ResetPosition();


            ulong npcGUID = ReadUInt64();
            if (ClientBuild >= 9183)
            {
                ulong itemguid = ReadUInt64();
            }
            uint QuestId = ReadUInt32();
            string Title = ReadString();
            string Details = ReadString();
            string Objectives = ReadString();
            UInt32 ActivateAccept = ReadUInt32();
            UInt32 GetSuggestedPlayers = ReadUInt32();

            if (ClientBuild >= 9183)
            {
                byte unb1 = ReadByte();

                if (ClientBuild >= 9767)
                {
                    byte unb2 = ReadByte();
                }
            }

            UInt32 RewChoiceItemsCount = ReadUInt32();
            for (int i = 0; i < RewChoiceItemsCount; i++)
            {
                UInt32 RewChoiceItemId = ReadUInt32();
                UInt32 RewChoiceItemCount = ReadUInt32();
                UInt32 DisplayInfoID = ReadUInt32();
            }

            UInt32 RewItemsCount = ReadUInt32();
            for (int i = 0; i < RewItemsCount; i++)
            {
                UInt32 RewItemId = ReadUInt32();
                UInt32 RewItemCount = ReadUInt32();
                UInt32 DisplayInfoID = ReadUInt32();
            }
            UInt32 tRewOrReqMoney = ReadUInt32();


            // rewarded honor points. Multiply with 10 to satisfy client
            UInt32 RewHonorableKills = ReadUInt32();
            UInt32 RewSpell = ReadUInt32();                 // reward spell, this spell will display (icon) (casted if RewSpellCast==0)
            UInt32 RewSpellCast = ReadUInt32();              // casted spell
            if (ClientBuild >= 8089)
            {
                UInt32 CharTitleId = ReadUInt32();               // CharTitleId, new 2.4.0, player gets this title (id from CharTitles)

                if (ClientBuild >= 9183)
                {
                    UInt32 BonusTalents = ReadUInt32();
                }
            }

            UInt32 QUEST_EMOTE_COUNT = ReadUInt32();
            for (int i = 0; i < QUEST_EMOTE_COUNT; i++)
            {
                UInt32 DetailsEmote = ReadUInt32(); ;
                UInt32 DetailsEmoteDelay = ReadUInt32(); ;                                 // DetailsEmoteDelay
            }

            return Validate();
        }
    }
}





//UInt64 guid = ReadUInt64(); //data << npcGUID;
//      UInt32 questid = ReadUInt32();//data << pQuest->GetQuestId() << Title << Details;
//      string title = ReadString();
//      string Details = ReadString();
//      string Objectives = ReadString();//data << Objectives;
//      UInt32 ActivateAccept = ReadUInt32();//data << (uint32)ActivateAccept;
//      UInt32 GetSuggestedPlayers = ReadUInt32();//data << pQuest->GetSuggestedPlayers();

//      UInt32 RewChoiceItemsCount = ReadUInt32();//data << pQuest->GetRewChoiceItemsCount();
//      for (int i = 0; i < RewChoiceItemsCount; i++)
//      {

//          UInt32 RewChoiceItemId = ReadUInt32(); //data << uint32(pQuest->RewChoiceItemId[i]);
//          UInt32 RewChoiceItemCount = ReadUInt32();//data << uint32(pQuest->RewChoiceItemCount[i]);
//          UInt32 DisplayInfoID = ReadUInt32();
//      }

//      UInt32 RewItemsCount = ReadUInt32();//data << pQuest->GetRewItemsCount();
//      for (int i = 0; i < RewItemsCount; i++)
//      {
//          //if (!pQuest->RewItemId[i]) continue;
//          UInt32 RewChoiceItemId = ReadUInt32(); //data << pQuest->RewItemId[i];
//          UInt32 RewChoiceItemCount = ReadUInt32();//data << pQuest->RewItemCount[i];
//          UInt32 DisplayInfoID = ReadUInt32();
//      }

//      // rewarded honor points. Multiply with 10 to satisfy client
//      UInt32 RewHonorablePoints = ReadUInt32();
//      UInt32 RewSpell = ReadUInt32();                // reward spell, this spell will display (icon) (casted if RewSpellCast==0)
//      UInt32 RewSpellCast = ReadUInt32();             // casted spell
//      if (ClientBuild >= 8089)
//      {
//          UInt32 CharTitleId = ReadUInt32();               // CharTitleId, new 2.4.0, player gets this title (id from CharTitles)
//      }

//      //UInt32 RewOrReqMoney = ReadUInt32(); //data << uint32(pQuest->GetRewOrReqMoney());
//      //UInt32 rewardspell = ReadUInt32();
//      //UInt32 castspell = ReadUInt32(); //data << uint32(pQuest->GetRewSpell());                  // cast spell
//      //UInt32 unk = ReadUInt32();//data << uint32(0);                                      // unk 2.3.0,  Honor points

//      UInt32 questemotecount = ReadUInt32();//data << uint32(QUEST_EMOTE_COUNT);
//      for (int i = 0; i < questemotecount; i++)
//      {
//          UInt32 DetailsEmote = ReadUInt32();//data << pQuest->DetailsEmote[i];
//          byte DetailsEmoteDelay = ReadByte();//data << uint32(0);                                  // DetailsEmoteDelay
//      }